package com.leyou.controller;

import com.leyou.service.PageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

import java.util.Map;

/**
 * @author HeGuanChao
 * @Description TODO
 * @Date 2020/4/9 15:31
 */
@Controller
public class PageController {
    @Autowired
    private PageService pageService;

    @GetMapping("/item/{id}.html")
    public String toItemHtml(@PathVariable("id") Long id, Model model) {
        // 查询模型数据
        Map<String, Object> itemData = pageService.loadItemData(id);
        // 存入model
        model.addAllAttributes(itemData);
        return "item";
    }
}
